package com.bolt.auth.admin.api.sys.dto;

import com.bolt.convention.data.BaseDTO;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * Created by Administrator on 2020/9/28.
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class MenuDTO extends BaseDTO {

    private Long id;

    @NotBlank
    @ApiModelProperty(notes = "菜单名称")
    private String title;

    @ApiModelProperty(notes = "菜单URL")
    private String url;

    @ApiModelProperty(notes = "菜单图标")
    private String icon;

    @ApiModelProperty(notes = "菜单说明")
    private String description;

    private Long pid;

    @ApiModelProperty(notes = "菜单排序号")
    private Integer orderRank;

    @ApiModelProperty(notes = "子节点个数")
    private Integer subCount;

    @ApiModelProperty(notes = "是否嵌入iFrame")
    private Boolean iFrame = false;

    @ApiModelProperty(notes = "是否嵌入iFrame")
    private Boolean cache = false;

    @ApiModelProperty(notes = "VUE组件名称")
    private String componentName;

    private String component;


    private List <MenuDTO> children;

    private Boolean hidden;

    @NotNull
    @ApiModelProperty(notes = "菜单是否可用")
    private Boolean enabled;

    private Integer childrenSize = 0;

    private Integer level;

    private String privilegeId;


    private Integer versionNO;

    public Boolean getHasChildren() {
        return childrenSize > 0;
    }

    public Boolean getLeaf() {
        return childrenSize == 0;
    }

    public String getLabel() {
        return title;
    }

    public Integer getType() {
        return this.pid == null || 0 == this.pid ? 0 : 1;
    }

}

 